/**
 * Project Name:design-pattern <br/>
 * File Name:Duck.java <br/>
 * Package Name:com.ftu.study.pattern.template <br/>
 */
package com.ftu.study.pattern.template;

/**
 * <p>  </p>
 * @version 1.0 2018年12月3日 mq 
 */
public class Duck implements Comparable<Duck> {
    String name;
    int weight;
    
    /**
     * 
     */
    public Duck(String name, int weight) {
        this.name = name;
        this.weight = weight;
    }
    @Override
    public String toString() {
        return "Duck [name=" + name + ", weight=" + weight + "]";
    }

    /* (non-Javadoc)
     * @see java.lang.Comparable#compareTo(java.lang.Object)
     */
    @Override
    public int compareTo(Duck o) {
        if(this.weight < o.weight) {
            return -1;
        } else if(this.weight == o.weight) {
            return 0;
        } else {
            return 1;
        }
    }

}
